package top.shen33.yang.services.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import top.shen33.yang.mapper.SysUserMapper;
import top.shen33.yang.model.entity.SysUser;
import top.shen33.yang.services.SysUserService;

import java.util.List;

/**
 * <p>
 * 用户 服务实现类
 * </p>
 *
 * @author shen
 * @since 2018-07-16
 */
@Service
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements SysUserService {

//    @Autowired
//    private SysUserMapper sysUserMapper;


    @Override
    public Class clazz() {
        return SysUser.class;
    }


    @Override
    public SysUser selectTestById(Integer id) {
        return this.selectTestById(id);
    }



    @Override
    @Transactional
    public void doAdd(SysUser sysUser) {

        sysUser.insertOrUpdate();
    }

    @Override
    @Transactional
    public void doUpdate(SysUser sysUser) {

        sysUser.insertOrUpdate();
    }

    @Override
    @Transactional
    public void doDelete(String[] ids) {

        QueryWrapper<SysUser> ew = new QueryWrapper<>();
        ew.in("sid",ids);
        new SysUser().delete(ew);
    }

    @Override
    public Page<SysUser> pageInfo(Page page, SysUser sysUser) {

        List<SysUser> dataList=this.baseMapper.pageInfo(page, sysUser);

        page.setRecords(dataList);
        return page;
    }

    @Override
    public List<SysUser> all(SysUser sysUser) {
        return null;
    }

    @Override
    @Transactional
    public void doImport(List<SysUser> dataList) {

    }

    @Override
    public SysUser getOne(String id) {

        //关联查询

        //
        SysUser sysUser = getById(id);

        //属性设置

        return sysUser;
    }
}
